<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<%
	request.setCharacterEncoding("utf-8");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>-.-</title>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/bootstrap.min.js"></script>
<link rel="stylesheet" href="styles/bootstrap.min.css">

</head>

<body>


	<div class="panel panel-default">
		<div class="panel-body">
			<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
				aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content"></div>
				</div>
			</div>


			<form class="form-inline" role="form"
				action="Order_searchingOrder.action" method="post"
				style="float: left">
				<div class="form-group">

					<input id="search" type="text" class="form-control" name="keyword" value="<s:property value="#session.keyword"/>"
						placeholder="请输入订单号">
				</div>
				<div class="form-group">
					<button type="submit" class="btn btn-info">搜索</button>
				</div>

			</form>
		</div>


		<table class="table table-hover table-condensed">
			<thead class="row">
				<tr>
					<th width="10%">订单号</th>
					<th width="10%">创建时间</th>
					<th width="5%">订单状态</th>
					<th width="10%">订单总价</th>
					<th width="10%">顾客</th>
					<th width="20%">家具信息</th>
					<th width="10%">收货人</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="#session.pageBean.list">
					<tr
						<s:if test="orderState==0">
                            				class="active"
                            		</s:if>
						<s:elseif test="orderState==1">
                            				class="success"
                            		</s:elseif>
						<s:else>class="danger"</s:else>>
						
						<td><s:property value="objId" /><input type="hidden" id="obj"  value="<s:property value="objId" />"/></td>
						<td><s:date name="createTime" format="yyy-MM-dd" /></td>
						<td><s:if test="orderState==0">
		                            				待处理
		                            		</s:if> <s:elseif test="orderState==1">
		                            				完成
		                            		</s:elseif> <s:else>已取消</s:else></td>
						<td><s:property value="totalPrice" />元</td>
						<td><s:property value="theCustomer.realName" /></td>
						<td>
								<table class="table">
									<thead>
										<tr>
												<th width="60%">家具名称</th>
												<th width="40%">家具图片</th>
										</tr>
									</thead>
									<tbody>
										<s:iterator value="orderItem">
											<tr>
												<td><s:property value="theFurnitureInfo.furnitureName" /></td>
												<td><img src="<s:property value="theFurnitureInfo.picture_one"/>"height="60dp" width="60dp"></td>
											</tr>
										</s:iterator>
									</tbody>
								</table>
							</td>
						<td><s:property value="theConsignee.consigneeName" /></td>
						<td align="center">
						<shiro:hasPermission name="order:list:view">
							<a href="Order_findOrderDetail.action?orders.objId=<s:property value="objId"/>"
										data-toggle="modal" data-target="#myModal"><span
										style="padding-right: 1em;" class="glyphicon glyphicon-file"></a>
						</shiro:hasPermission>
						<shiro:hasPermission name="order:list:update">
							<a href="Order_findEditOrder.action?orders.objId=<s:property value="objId"/>"
										data-toggle="modal" data-target="#myModal"><span
										style="padding-right: 1em;" class="glyphicon glyphicon-pencil"></a>
						</shiro:hasPermission>
<%-- 						<a href="Order_deleteOrder.action?orders.objId=<s:property value="objId"/>"><span
									class="glyphicon glyphicon-trash"></span></a> --%>
						<shiro:hasPermission name="order:list:delete">
							<a onclick="delOrder()"><span class="glyphicon glyphicon-trash"></span></a>
						</shiro:hasPermission>
<%-- 						<input type="button"
							href="Order_findOrderDetail.action?orders.objId=<s:property value="objId"/>"
							data-toggle="modal" data-target="#myModal" value="详情" class="btn" />
							<input type="button"
							href="Order_findEditOrder.action?orders.objId=<s:property value="objId"/>"
							data-toggle="modal" data-target="#myModal" value="修改" class="btn" />
							<input type="button" value="删除" class="btn"
							onclick="delOrder(<s:property value="objId"/>)"> --%>
							</td>
					</tr>
				</s:iterator>
			</tbody>
		</table>
</div>

		<table border="0" cellspacing="0" cellpadding="0" width="900px">
			<tr>
				<td align="right" colspan="5">
					<span> 第<s:property value="#session.pageBean.pageIndex" />/<s:property
							value="#session.pageBean.pageSize" />页
				</span> <span> 总记录数：<s:property value="#session.pageBean.count" />
						每页显示:<s:property value="#session.pageBean.pageCount" /></span> <span>
						<s:if test="#session.pageBean.pageIndex != 1">
						
							<input type="button" value="首页" class="btn"  onclick="page(1)" />
							<input type="button" value="上一页" class="btn"  onclick="page(<s:property value="#session.pageBean.pageIndex-1"/>)" />
							
						</s:if> <s:if
							test="#session.pageBean.pageIndex != #session.pageBean.pageSize">
							<input type="button" value="下一页" class="btn"  onclick="page(<s:property value="#session.pageBean.pageIndex+1"/>)" />
						
							<input type="button" value="尾页" class="btn"  onclick="page(<s:property value="#session.pageBean.pageSize"/>)" />
							
						</s:if>
				</span>
				</td>
			</tr>
		</table>


</body>
<script type="text/javascript">
	function page(pageindex) {
		var val=document.getElementById("search").value;
		window.location="Order_searchingOrder.action?pageIndex="+pageindex+"&keyword="+encodeURI(encodeURI(val));
	}

	function addUser(){
		window.location="Order_showAddOrder.action";	
	}
	function editOrder(id){

			window.location="Order_findEditOrder.action?orders.objId="+id;
	}
	function search(){
		if(event.keyCode==13){
			var val=document.getElementById("search").value;
			window.location="Order_searchingOrder.action?keyword="+encodeURI(encodeURI(val));
		}
	}
	function delOrder(){
		
		var val=document.getElementById("obj").value;
			if(window.confirm("您确定要删除吗？删除之后不可以恢复哦！！！"+val)){
				window.location="Order_deleteOrder.action?orders.objId="+val;
			}
	}

	
	$('#myModal').on("hide.bs.modal", function(event){
		$(this).removeData("bs.modal");
	});
	
	</script>
</html>